<template>
  <div class="toop-tip-box">

    <div class="color-box">
      <div v-for="item in colors" :key="item.color">
        <div
          class="item-color-1 item"
          :style="item.background"
          @click="changTheme(item.color)"
        ></div>
      </div>
      <div class="drapdown-icon">
        <input
          type="color"
          class="color-input"
          v-model="colorRef"
          @change="colorChange()"
          @input="colorChange()"
        />
      </div>
    </div>
  </div>
</template>

<script>
import {mapGetters} from 'vuex'
export default {
  data() {
    return {
      colors: [
        { color: 'rgb(6,39,67)', background: 'background-color:rgb(6,39,67)' },
        { color: 'rgb(104, 65, 44)', background: 'background-color:rgb(104, 65, 44)' },
        { color: '#25252a', background: 'background-color:#25252a' },
        { color: 'rgb(29, 99, 87)', background: 'background-color:rgb(29, 99, 87)' },
        { color: 'rgb(48, 65, 130)', background: 'background-color:rgb(48, 65, 130)' },
      ],
      colorRef:''
    }
  },
  computed:{
    ...mapGetters(['myThemeColor'])
  },
  methods:{
    changTheme(color){
      this.$store.commit('setThemeColor',color);
    },
    colorChange(){
      this.$store.commit('setThemeColor',this.colorRef);
    }
  },
  created(){
    this.colorRef = this.myThemeColor || '#EB5505'
  }
}
</script>

<style lang="less" scoped>

button {
  width: 100px;
}

.item-color-1 {
  background-color: #25252a;
}
.item-color-2 {
  background-color: #efb788;
}
.item-color-3 {
  background-color: #7194a9;
}
.item-color-4 {
  background-color: #795548;
}
.item-color-5 {
  background-color: #a487d8;
}
.item-color-6 {
  background-color: #4caf50;
}

.item {
  width: 16px;
  height: 16px;
  margin: 10px 0;
}

.item:hover {
  border: 1px rgb(14, 11, 11) solid;
  cursor: pointer;
}

.toop-tip-box {
  display: flex;
  flex-direction: column;
  width: 40px;
  height: 260px;
  position: fixed;
  border: 1px #e2e1e1 solid;
  right: 50px;
  top: 200px;
  align-items: center;
  justify-content: space-around;
  .color-box {
    width: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
  }

  .drapdown-icon {
    // width: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .drapdown-icon:hover {
    cursor: pointer;
  }
  .menu-btn {
    background-color: transparent;

    &:hover {
      background-color: #928f8a33;
    }
  }
}

.color-input {
  padding: 0;
  width: 20px;
  height: 24px;
  line-height: 30px;
  border: 0px;
  margin: 10px;
  border-radius: 5px;
  background-color: transparent;
}
</style>
